import { observable, action,makeObservable } from 'mobx';
import moment from "moment";
import { currentUser } from "@/services/auth";
import GlobalFunctions from '@/store/globalFunctions';

class ContractChangeModel {
    @observable id= 0;//
    @observable userid=currentUser.id;//--操作员ID
    @observable bill_date=moment();//--申请日期
    @observable employeeid=currentUser.id;//--经办人
    @observable departmentid=currentUser.orgunit_id;//--经办部门
    @observable code= "";//----合同编号
    @observable name= "";//--合同名称
    @observable type= "";//----合同类别
    @observable contracttype= [];
    @observable party_aid= "";//----甲方ID
    @observable party_bid= "";//--乙方
    @observable party_cid= "";//----其它关联方
    @observable pay_direction= 1;//-收付款类型0-fukuan,1-shoukuan
    @observable infrastructure= 0;//
    @observable zhengcai= 0;//0非政采，1政采
    @observable iskeyan= 0;//
    @observable iszhaobiao= 1;//
    @observable warnsealuser= "";//
    @observable isbulu= 0;//0正常，1补录
    @observable pricetype= 0;//
    @observable sign_date= null;//合同签订日期
    @observable start_date= null;//合同开始日期
    @observable end_date= null;//合同终止日期
    @observable sign_dateold= null;//合同签订日期
    @observable start_dateold= null;//合同开始日期
    @observable end_dateold= null;//合同终止日期
    @observable warn_date= null;//提醒日期
    @observable warn_message= "";//提醒内容
    @observable warn_dateold= null;//提醒日期
    @observable warn_messageold= "";//提醒内容
    @observable warn_check= "";//审核提醒
    @observable warn_checkdate= null;//
    @observable volumepurchase= 0;//
    @observable amount= "0.00";//
    @observable amount_words= "";//
    @observable amounttype= [];//
    @observable status= 0;//
    @observable officialcode= "";//
    @observable budgetcode= "";//
    @observable recordcode= "";//
    @observable recordcodeold= "";//
    @observable puremployeeid= "";//
    @observable templateid= 0;//
    @observable templatecontent= "";//
    @observable message= "";//纪录事项
    @observable sourcetype= "";//
    @observable sourceid= 0;//
    @observable template_value= "";//
    @observable checkmessage= "";//
    @observable xiuzhengupload= false;//
    @observable empowerperson= "";//授权人
    @observable empowersex= "是";//性别
    @observable empowerduties= "";//职务
    @observable agreementcount= "肆";//协议份数
    @observable contractsid= "";//协议份数
    @observable contractcode= "";//协议份数
    @observable changebefore= {};//协议份数
    //===================   
    @observable isnew= true;
    @observable isedit=true; 
    @observable allow_col=[];
    @observable colcontrol=false;


    constructor(id) {
        this.id=id;    
        makeObservable(this);
    }
    
    @action setUserid(userid) {
        this.userid = userid;
    }
    @action setBill_date(bill_date) {
        this.bill_date = bill_date;
    }
    @action setBilledit(item) {
        this.isedit = item.edit;
        this.allow_col = item.allow_col;
        this.colcontrol = item.colcontrol;
    }
    @action setEmployeeid(employeeid) {
        this.employeeid = employeeid;
    }
    @action setDepartmentid(departmentid) {
        this.departmentid = departmentid;
    }
    @action setCode(code) {
        this.code = code;
    }
    @action setName(name) {
        this.name = name;
    }
    @action setType(type) {
        this.type = type;
    }
    @action setContracttype(contracttype) {
        this.contracttype = contracttype.split(",");
    }
    @action setParty_aid(party_aid) {
        this.party_aid = party_aid;
    }
    @action setParty_bid(party_bid) {
        this.party_bid = party_bid;
    }
    @action setParty_cid(party_cid) {
        this.party_cid = party_cid;
    }
    @action setPay_direction(pay_direction) {
        this.pay_direction = pay_direction;
    }
    @action setInfrastructure(infrastructure) {
        this.infrastructure = infrastructure;
    }
    @action setZhengcai(zhengcai) {
        this.zhengcai = zhengcai;
    }

    @action setIskeyan(iskeyan) {
        this.iskeyan = iskeyan;
    }
    @action setIszhaobiao(iszhaobiao) {
        this.iszhaobiao = iszhaobiao;
    }
    @action setWarnsealuser(warnsealuser) {
        this.warnsealuser = warnsealuser;
    }
    
    @action setIsbulu(isbulu) {
        this.isbulu = isbulu;
    }
    @action setPricetype(pricetype) {
        this.pricetype = pricetype;
    }
    @action setSign_date(sign_date) {
        this.sign_date = sign_date;
    }
    @action setStart_date(start_date) {
        this.start_date = start_date;
    }
    @action setEnd_date(end_date) {
        this.end_date = end_date;
    }
    @action setSign_dateold(sign_dateold) {
        this.sign_dateold = sign_dateold;
    }
    @action setStart_dateold(start_dateold) {
        this.start_dateold = start_dateold;
    }
    @action setEnd_dateold(end_dateold) {
        this.end_dateold = end_dateold;
    }
    @action setWarn_date(warn_date) {
        this.warn_date = warn_date;
    }
    @action setWarn_message(warn_message) {
        this.warn_message = warn_message;
    }
    @action setWarn_dateold(warn_dateold) {
        this.warn_dateold = warn_dateold;
    }
    @action setWarn_messageold(warn_messageold) {
        this.warn_messageold = warn_messageold;
    }
    @action setWarn_check(warn_check) {
        this.warn_check = warn_check;
    }
    @action setWarn_checkdate(warn_checkdate) {
        this.warn_checkdate = warn_checkdate;
    }
    @action setVolumepurchase(volumepurchase) {
        this.volumepurchase = volumepurchase;
    }
    @action setAmount(amount) {
        this.amount = amount;
    }
    @action setAmount_words(amount_words) {
        this.amount_words = amount_words;
    }
    @action setAmounttype(amounttype) {
        this.amounttype = amounttype;
    }
    @action setStatus(status) {
        this.status = status;
    }
    @action setOfficialcode(officialcode) {
        this.officialcode = officialcode;
    }
    @action setBudgetcode(budgetcode) {
        this.budgetcode = budgetcode;
    }
    @action setRecordcode(recordcode) {
        this.recordcode = recordcode;
    }
    @action setRecordcodeold(recordcodeold) {
        this.recordcodeold = recordcodeold;
    }
    @action setPuremployeeid(puremployeeid) {
        this.puremployeeid = puremployeeid;
    }
    @action setTemplateid(templateid) {
        this.templateid = templateid;
    }
    @action setTemplatecontent(templatecontent) {
        this.templatecontent = templatecontent;
    }
    @action setMessage(message) {
        this.message = message;
    }
    @action setSourcetype(sourcetype) {
        this.sourcetype = sourcetype;
    }
    @action setSourceid(sourceid) {
        this.sourceid = sourceid;
    }
    @action setTemplate_value(template_value) {
        this.template_value = template_value;
    }
    @action setCheckmessage(checkmessage) {
        this.checkmessage = checkmessage;
    }
    @action setXiuzhengupload(xiuzhengupload) {
        this.xiuzhengupload = xiuzhengupload;
    }
    @action setEmpowerperson(empowerperson) {
        this.empowerperson = empowerperson;
    }
    @action setEmpowersex(empowersex) {
        this.empowersex = empowersex;
    }
    @action setEmpowerduties(empowerduties) {
        this.empowerduties = empowerduties;
    }
    @action setAgreementcount(agreementcount) {
        this.agreementcount = agreementcount;
    }
    @action setContractsid(data) {
        this.bill_date= moment(data.bill_date);//--申请日期
        this.employeeid=data.employeeid;//--经办人
        this.departmentid=data.departmentid;//--经办部门
        this.code= data.code;//----合同编号
        this.name= data.name;//--合同名称
        this.type= data.type;//----合同类别
        this.contracttype= data.contracttype;
        this.party_aid= data.party_aid;//----甲方ID
        this.party_bid= data.party_bid;//--乙方
        this.party_cid= data.party_cid;//----其它关联方
        this.pay_direction= data.pay_direction;//-收付款类型0-fukuan,1-shoukuan
        this.infrastructure= data.infrastructure;//
        this.zhengcai= data.zhengcai;//0非政采，1政采
        this.iskeyan= data.iskeyan;//
        this.iszhaobiao= data.iszhaobiao;//
        this.warnsealuser=data.warnsealuser;
        this.pricetype= data.pricetype;//
        this.sign_date= data.sign_date ? (GlobalFunctions.isEmptyobj(data.sign_date) ? null : moment(data.sign_date)) : null;//合同签订日期
        this.start_date=data.start_date ? (GlobalFunctions.isEmptyobj(data.start_date) ? null : moment(data.start_date)) : null;//合同开始日期
        this.end_date= data.end_date ? (GlobalFunctions.isEmptyobj(data.end_date) ? null : moment(data.end_date)) : null;//合同终止日期
        this.sign_dateold= data.sign_date ? (GlobalFunctions.isEmptyobj(data.sign_date) ? null : moment(data.sign_date)) : null;//合同签订日期
        this.start_dateold= data.start_date ? (GlobalFunctions.isEmptyobj(data.start_date) ? null : moment(data.start_date)) : null;//合同开始日期
        this.end_dateold= data.end_date ? (GlobalFunctions.isEmptyobj(data.end_date) ? null : moment(data.end_date)) : null;//合同终止日期
        this.warn_date= data.warn_date ? (GlobalFunctions.isEmptyobj(data.warn_date) ? null : moment(data.warn_date)) : null;//提醒日期
        this.warn_message= data.warn_message;//提醒内容
        this.warn_dateold= data.warn_date ? (GlobalFunctions.isEmptyobj(data.warn_date) ? null : moment(data.warn_date)) : null;//提醒日期
        this.warn_messageold= data.warn_message;//提醒内容
        this.warn_check= data.warn_check;//审核提醒
        this.warn_checkdate= data.warn_checkdate ? (GlobalFunctions.isEmptyobj(data.warn_checkdate) ? null : moment(data.warn_checkdate)) : null;//
        this.volumepurchase= data.volumepurchase;//
        this.amount= data.amount;//
        this.amount_words=data.amount_words;//
        this.amounttype= data.amounttype;//
        this.officialcode= data.officialcode;//
        this.budgetcode= data.budgetcode;//
        this.recordcode= data.recordcode;//
        this.recordcodeold= data.recordcode;//
        this.puremployeeid= data.puremployeeid;//
        this.templateid= data.templateid;//
        this.templatecontent= data.templatecontent;//
        this.message= data.message;//纪录事项
        this.sourcetype= 'contracts';//
        this.sourceid= data.id;//
        this.template_value= data.template_value;//
        this.checkmessage= data.checkmessage;//
        this.empowerperson= data.empowerperson;//授权人
        this.empowersex= data.empowersex;//性别
        this.empowerduties= data.empowerduties;//职务
        this.agreementcount= data.agreementcount;//协议份数
        this.contractsid= data.id;//协议份数
        this.contractcode= data.officialcode;//协议份数
        this.changebefore= data;//协议份数
        this.isbulu = data.isbulu;
    }
    @action setContractcode(contractcode) {
        this.contractcode = contractcode;
    }
    @action setChangebefore(changebefore) {
        this.changebefore = changebefore;
    }
    static fromJS(obj) {
        let m =  new ContractChangeModel(obj.id);
        m.userid= obj.userid ;
        m.bill_date= moment(obj.bill_date);//--申请日期
        m.employeeid=obj.employeeid;//--经办人
        m.departmentid=obj.departmentid;//--经办部门
        m.code= obj.code;//----合同编号
        m.name= obj.name;//--合同名称
        m.type= obj.type;//----合同类别
        m.contracttype= obj.contracttype;
        m.party_aid= obj.party_aid;//----甲方ID
        m.party_bid= obj.party_bid;//--乙方
        m.party_cid= obj.party_cid;//----其它关联方
        m.pay_direction= obj.pay_direction;//-收付款类型0-fukuan,1-shoukuan
        m.infrastructure= obj.infrastructure;//
        m.zhengcai= obj.zhengcai;//0非政采，1政采
        m.iskeyan= obj.iskeyan;//
        m.iszhaobiao= obj.iszhaobiao;//
        m.warnsealuser=obj.warnsealuser;
        m.pricetype= obj.pricetype;//
        m.sign_date= obj.sign_date ? (GlobalFunctions.isEmptyobj(obj.sign_date) ? null : moment(obj.sign_date)) : null;//合同签订日期
        m.start_date=obj.start_date ? (GlobalFunctions.isEmptyobj(obj.start_date) ? null : moment(obj.start_date)) : null;//合同开始日期
        m.end_date= obj.end_date ? (GlobalFunctions.isEmptyobj(obj.end_date) ? null : moment(obj.end_date)) : null;//合同终止日期
        m.sign_dateold= obj.sign_date ? (GlobalFunctions.isEmptyobj(obj.sign_date) ? null : moment(obj.sign_date)) : null;//合同签订日期
        m.start_dateold= obj.start_date ? (GlobalFunctions.isEmptyobj(obj.start_date) ? null : moment(obj.start_date)) : null;//合同开始日期
        m.end_dateold= obj.end_date ? (GlobalFunctions.isEmptyobj(obj.end_date) ? null : moment(obj.end_date)) : null;//合同终止日期
        m.warn_date= obj.warn_date ? (GlobalFunctions.isEmptyobj(obj.warn_date) ? null : moment(obj.warn_date)) : null;//提醒日期
        m.warn_message= obj.warn_message;//提醒内容
        m.warn_dateold= obj.warn_date ? (GlobalFunctions.isEmptyobj(obj.warn_date) ? null : moment(obj.warn_date)) : null;//提醒日期
        m.warn_messageold= obj.warn_message;//提醒内容
        m.warn_check= obj.warn_check;//审核提醒
        m.warn_checkdate= obj.warn_checkdate ? (GlobalFunctions.isEmptyobj(obj.warn_checkdate) ? null : moment(obj.warn_checkdate)) : null;//
        m.volumepurchase= obj.volumepurchase;//
        m.amount= obj.amount;//
        m.amount_words=obj.amount_words;//
        m.amounttype= obj.amounttype;//
        m.status= obj.status;//
        m.officialcode= obj.officialcode;//
        m.budgetcode= obj.budgetcode;//
        m.recordcode= obj.recordcode;//
        m.recordcodeold= obj.recordcode;//
        m.puremployeeid= obj.puremployeeid;//
        m.templateid= obj.templateid;//
        m.templatecontent= obj.templatecontent;//
        m.message= obj.message;//纪录事项
        m.sourcetype= obj.sourcetype;//
        m.sourceid= obj.sourceid;//
        m.template_value= obj.template_value;//
        m.checkmessage= obj.checkmessage;//
        m.empowerperson= obj.empowerperson;//授权人
        m.empowersex= obj.empowersex;//性别
        m.empowerduties= obj.empowerduties;//职务
        m.agreementcount= obj.agreementcount;//协议份数
        m.contractsid= obj.contractsid;//协议份数
        m.contractcode= obj.contractcode;//协议份数
        m.changebefore=JSON.parse(obj.changebefore) ;//协议份数
        m.isbulu = obj.isbulu;
        m.isnew= false;
        return m;
    }
}

export default ContractChangeModel;